import 'package:flutter/material.dart';

void go(BuildContext context,Widget curr,Widget dest){
  // Navigator.push(context, EnterExitRoute(exitPage: curr, enterPage: dest));
  // Navigator.push(context, CupertinoPageRoute(builder: (context)=>dest,));
  Navigator.push(context, MaterialPageRoute(builder: (context) => dest));
}

class EnterExitRoute extends PageRouteBuilder {
  final Widget enterPage;
  final Widget exitPage;
  EnterExitRoute({required this.exitPage, required this.enterPage})
      : super(pageBuilder: (context, animation, secondaryAnimation,) => enterPage,
    transitionDuration: const Duration(milliseconds: 150),
    reverseTransitionDuration: const Duration(milliseconds: 150),

    transitionsBuilder: (context, animation, secondaryAnimation, child) =>
        Stack(
          children: <Widget>[
            SlideTransition(
              position: new Tween<Offset>(
                begin: const Offset(0.0, 0.0),
                end: const Offset(-1.0, 0.0),
              ).animate(animation),
              child: exitPage,
            ),
            SlideTransition(
              position: new Tween<Offset>(
                begin: const Offset(1.0, 0.0),
                end: Offset.zero,
              ).animate(animation),
              child: enterPage,
            )
          ],
        ),
  );
}
